<!DOCTYPE HTML>
<html>
<head>
    <title>查看空房</title>
    <% include common/meta.ejs %>
    <% include common/public.ejs %>
</head>
<body ontouchstart="">
<div class="weui_cells weui_cells_form" style="margin-top: 10px;">
    <div class="weui_cell">
        <div class="weui_cell_bd weui_cell_primary">
            <% for (var city of data.cityList) { %>
            <a href="houseSearch?groupFlag=1&openId=<%= session.openId %>&city=<%= city.code %>" class="weui_btn weui_btn_mini <%= (!queryData.city || queryData.city=='001')?'weui_btn_warn':'weui_btn_default' %>"><%= city.name %></a>
            <% } %>

            <!--<a href="houseSearch?groupFlag=1&openId=<%= session.openId %>&city=001"
               class="weui_btn weui_btn_mini <%= (!queryData.city || queryData.city=='001')?'weui_btn_warn':'weui_btn_default'%>">杭州</a>
            <a href="houseSearch?groupFlag=1&openId=<%= session.openId %>&city=002"
               class="weui_btn weui_btn_mini <%= queryData.city=='002'?'weui_btn_warn':'weui_btn_default'%>">绍兴</a>
            <a href="houseSearch?groupFlag=1&openId=<%= session.openId %>&city=003"
               class="weui_btn weui_btn_mini <%= queryData.city=='003'?'weui_btn_warn':'weui_btn_default'%>">无锡</a>-->
        </div>
    </div>
    <div class="weui_cell">

        <div class="weui_cell_hd"><label class="weui_label">入住日期</label></div>
        <div class="weui_cell_bd weui_cell_primary">
            <input class="weui_input" id="checkInDate" type="text" placeholder="">
        </div>
    </div>
</div>
<%
var houseType = {};
var tempArray = data.houseType;
for(let idx of tempArray.keys()){
    houseType[tempArray[idx].code] = tempArray[idx].name;
}
%>
<div class="weui_panel weui_panel_access">
    <div class="weui_panel_hd">
        查询结果
    </div>
    <div class="weui_panel_bd">
        <% for(var i = 0;i < data.houseList.length;i++) { %>
        <a href="houseInfo?groupFlag=1&apartmentCity=<%= data.houseList[i].apartmentCity %>&houseGroup=<%= data.houseList[i].houseGroup %>" class="weui_media_box weui_media_text weui_media_appmsg">
            <div class="weui_media_hd">
                <img class="weui_media_appmsg_thumb"
                     src="<%= '/yams-upload' + (data.houseList[i].primaryImage || '/images/noImage.png') %>"
                     alt="">
            </div>
            <div class="weui_media_bd">
                <span class="weui_media_title" style="font-size: 0.75rem;"><%= data.houseList[i].shortDesc %></span>
                <p class="weui_media_desc">
                    <%= data.houseList[i].name %>
                    <span style="color: #0BB20C;">可入住</span>
                </p>
                <ul class="weui_media_info" style="color: #666;">
                    <li class="weui_media_info_meta"><%= houseType[data.houseList[i].houseType] %></li>
                    <li class="weui_media_info_meta"><%= data.houseList[i].area + '平米' %></li>
                    <li class="weui_media_info_meta weui_media_info_meta_extra">
                        <strong><%= data.houseList[i].monthly %>元/月</strong></li>
                </ul>
            </div>
        </a>
        <% } %>
    </div>
</div>
<% include common/footer.ejs %>
<script>
    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        return year + seperator1 + month + seperator1 + strDate;
    }

    var curDate = "<%= queryData.selDay %>";
    if (!curDate)
        curDate = getNowFormatDate();
    $("#checkInDate").val(curDate).calendar({
        minDate: curDate,
        onChange: function (p, values, disV) {
            console.log(values, disV);

        }
    }).change(function () {
        if ($(this).val() != curDate)
            location.href = "houseSearch?groupFlag=1&selDay=" + $(this).val();
    });

</script>
</body>
</html>